package com.stillcoolme.framework.util;


import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.RandomStringUtils;

import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.List;

public class MockDataHonorOfKingsUtil {

    //开始时间
    private static long startTime = LocalDateTime.of(2020, 1, 1, 0, 0, 0).toInstant(ZoneOffset.of("+8")).toEpochMilli();
    //结束时间
    private static long endTime = LocalDateTime.of(2021, 1, 1, 0, 0, 0).toInstant(ZoneOffset.of("+8")).toEpochMilli();

    public static void main(String[] args) throws IOException {
        //声明一个容器存放数据
        List<String> recordList = new ArrayList<>();
        //数据格式：平台,大区,用户名，充值时间，性别，充值金额
        for (int i = 0; i < 10000; i++) {
            //随机平台
            String platform = Math.random() > 0.5 ? "安卓" : "微信";
            //随机大区
            int area = (int) (Math.random() * 100 + 1);
            //随机用户名
            String username = RandomStringUtils.randomAlphanumeric(10);
            //随机时间
            long time = (long) (Math.random() * (endTime - startTime) + startTime);
            //随机性别
            String gender = Math.random() > 0.01 ? "man" : "woman";
            //随机充值金额
            BigDecimal bigDecimal = new BigDecimal(Math.random() * 648 + 1).setScale(2, RoundingMode.HALF_UP);
            //存放数据
            recordList.add(platform + "," + area + "," + username + "," + time + "," + gender + "," + bigDecimal);
        }
        //将数据写出到文件
        FileUtils.writeLines(new File("mockdata/HonorOfKings.txt"), recordList);
    }
}